package org.jmh.auth.controller;

import org.jmh.auth.domain.EmployeeRole;
import org.jmh.auth.dto.LoginDTO;
import org.jmh.auth.query.EmployeeRoleQuery;
import org.jmh.auth.service.IEmployeeRoleService;
import org.jmh.auth.service.ILoginService;
import org.jmh.auth.vo.LoginVO;
import org.jmh.base.util.AjaxResult;
import org.jmh.base.util.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService service;
    /*
    *登陆成功返回token和user
    * 当返回的结果不是domain使用一个VO View Object
    * */

    @PutMapping
    public AjaxResult addOrUpdate(@RequestBody LoginDTO loginDTO){
        try {
            LoginVO loginVO = service.login(loginDTO);
            return AjaxResult.success(loginVO);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("登录不上去，多想想自己的原因！"+e.getMessage());
        }
    }

}
